const path = require('path');
const webpack = require('webpack');

function resolve(dir) {
	return path.join(__dirname, dir);
}
module.exports = {
	chainWebpack: (config) => {
		config.module
			.rule('css')
			.test(/\.css$/)
			.oneOf('vue')
			.resourceQuery(/\?vue/)
			.use('px2rem')
			.loader('px2rem-loader')
			.options({
				remUnit: 75,
			});
	},
	configureWebpack() {
		return {
			resolve: {
				alias: {
					'@': resolve('src'),
				},
				fallback: {
					path: require.resolve('path-browserify'),
					util: require.resolve('util/'),
					stream: require.resolve('stream-browserify'),
				},
			},
		};
	},
	// devServer: {
	// 	proxy: {
	// 		'/': {
	// 			target: 'http://localhost:3000/', // 本地后端地址
	// 			changeOrigin: true, //允许跨域
	// 			ws: false,
	// 		},
	// 	},
	// },
};
